Skip to content

Add algorithms - #243

Open
cat923 wants to merge 6 commits into
SparseLinearAlgebra:mainfrom
cat923:algorithms
Open

Add algorithms#243
cat923 wants to merge 6 commits into
SparseLinearAlgebra:mainfrom
cat923:algorithms

Conversation

@cat923

@cat923 cat923 commented Jul 16, 2026

Copy link
Copy Markdown

Implemented graph algorithms and test coverage for result comparison between Classic and SPLA versions.
Added project documentation with usage instructions and input format examples.
Added graph input readers for both vectors (.txt) and Matrix Market (.mtx) formats.

Comment thread python/RUFF.md
@@ -0,0 +1,16 @@
# Install ruff to check your code style :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it for?

@@ -0,0 +1,21 @@
from collections import deque

INF = int(1e9)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you need distance and infinite in BFS?

depth += 1
count += front_size
v.assign(front, depth, op_assign=INT.SECOND, op_select=INT.NQZERO)
front = front.vxm(v, A, op_mult=INT.LAND, op_add=INT.LOR, op_select=INT.EQZERO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How you prevent repeated visiting of vertices?

return graph, n


def read_mtx_weighted(filename):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it helper for MTX reading? Can we use standard functions to do it?

from pyspla import FLOAT, INT, Matrix


def read_mtx_int(filename):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many helpers with duplicated code. There are standard functions for mtx reading.

read_vectors_weighted,
)
from pr_classic import pagerank_classic
from sssp_classic import INF as SSSP_INF

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet another inf?

from tc_spla import cohen


def main():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you duplicate code?

import math


def pagerank_classic(adj_in, out_degree, n, alpha, eps):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to implement it again? can you use existing reference implementation?

@@ -0,0 +1,14 @@
INF = 1e9

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not an infinity....

@@ -0,0 +1,41 @@
from pyspla import FLOAT, Matrix, Scalar, Vector

INF = float(1e9)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infinity can be represented in floats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants